var ClubInviteWindow = Window.extend({
    _ccsFileName: res.ClubInviteWindow_json,
    _clubInfo: null,
    _clubId: null,
    initWindow: function (clubId) {
        this._clubId = clubId;
        this._clubInfo = ClubDataManager.getClubData(clubId);
    },

    _initClickListeners: function () {
        this._clickListeners = {
            'btn_winxin': '_clickWeXin',
            'btn_liaobei': '_clickLiaoBei',
            'btn_xianliao': '_clickXianLiao',
            'btn_invite': '_clickInvite',
        }
    },

    _clickWeXin: function () {
        this.shareClub('wx');
    },
    _clickLiaoBei: function () {
        this.shareClub('lb');
    },
    _clickXianLiao: function () {
        this.shareClub('xl');
    },
    _clickInvite: function () {
        showWindow('ClubJoinOrInviteWindow', ClubJoinOrInviteWindow_Type.Invite,this._clubId);
    },

    shareClub: function (platform) {
        var clubData = this._clubInfo;
        var title = app.appName + "-亲友圈";
        var description = "玩家[" + gameData.nickname + "]邀请您加入亲友圈[" + clubData['name'] + "]，亲友圈ID[" + clubData['_id'] + "]" + "速度来啊! 【" + app.appName + "】";
        var clubID = clubData['_id'].toString();
        var strID = "";
        for (var i = clubID.length; i < 6; i++) {
            strID = strID + "0";
        }
        strID = strID + clubID;
        var url = app.shareClubUrl + '?roomid=' + strID;
        if (gameData.link == 2) {
            url = url
                + "&inviterHead=" + gameData.headimgurl
                + "&club=" + encodeURIComponent(clubData['name'])
                + '&inviterName=' + encodeURIComponent(gameData.nickname)
                + '&creatorHead=' + clubData['head']
                + '&clubNum=' + clubData['players_count']
                + '&creatorName=' + encodeURIComponent(clubData['nick']);
        }

        console.log("shareurl:" + url);

        switch (platform) {
            case 'xl':
                XianLiaoUtil.shareGame(strID, title, description);
                break;
            case 'lb':
                LiaoBeUtil.shareUrl(url, title, description);
                break;
            case 'wx':
                WeChatUtil.shareUrl(url, title, description, 0);
                break;
        }
    }

});